//
//  GCMTaskDetailViewController.m
//  GeeCityManager
//
//  Created by 聚城科技 on 16/3/22.
//  Copyright © 2016年 聚城科技. All rights reserved.
//

#import "GCMTaskDetailViewController.h"
#import "GCMLXKHViewController.h"
#import "GCMAddNewLXJLViewController.h"
#import "GCMReciveDetailViewController.h"
#import "GCMCloseTaskViewController.h"
#import "GCMSLRViewController.h"

@interface GCMTaskDetailViewController ()<UIScrollViewDelegate,UIAlertViewDelegate>

@end



@implementation GCMTaskDetailViewController{

    UIButton *_ckjdBtn;
    UIButton *_jsrwBtn;
    UIButton *_lxkhBtn;
    UIButton *_yjxhBtn;
    UIButton *_gbrwBtn;
    UIView *_view1;
    UIView *_view21;
    UIView *_view22;
    UIView *_view23;
    UIView *_view3;
    UIView *_view4;
    UIView *_view5;
    UIScrollView *_scrollV;
    
    NSArray *_Array;
    NSDictionary *_dataDic;
    UILabel *_labelview4;
    
    UILabel *_jsmsLabel;
    
}
-(void)viewWillAppear:(BOOL)animated{
    
    if ([self.type isEqualToString:@"1"]) {
        self.navigationController.navigationBarHidden = NO;
    }
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createScrollView];
    [self downLoadData];
     
    
}

-(void)downLoadData{

    [GCMTaskHttpRequst postTaskListDataWithtaskId:self.idd Success:^(id obj, NSError *err) {
       _Array = obj ;
        _dataDic = [CZHChangeNullString getValueFromDictionary:[_Array valueForKey:@"data"]];
        NSLog(@"111%@",_dataDic);
        [self createUI];
    }];
}

-(void)createScrollView{
    
    //    创建可以滑动的视图
    _scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 64 +40, SCREEN_WIDTH, SCREEN_HEIGHT - 104)];
    //_scrollV.backgroundColor = [UIColor blueColor];
    _scrollV.delegate = self;
    _scrollV.pagingEnabled = NO;
    _scrollV.alwaysBounceHorizontal = NO;
    _scrollV.alwaysBounceVertical = NO;
    _scrollV.showsHorizontalScrollIndicator = NO;
    _scrollV.showsVerticalScrollIndicator = NO;
    _scrollV.bounces = NO;
    _scrollV.contentOffset = CGPointMake(0, 0);
    _scrollV.contentSize = CGSizeMake(SCREEN_WIDTH, 650 );
    _scrollV.backgroundColor = [UIColor colorWithRed:.95 green:.95 blue:.95 alpha:1.0];
    self.automaticallyAdjustsScrollViewInsets = NO;
    [self.view addSubview:_scrollV];
    
}


-(void)createUI{

    _ckjdBtn  = [[UIButton alloc]initWithFrame:CGRectMake(5, 5 +64, (SCREEN_WIDTH - 14)/5, 30)];
    _ckjdBtn.backgroundColor = [UIColor colorWithRed:0.75 green:0.22 blue:0.17 alpha:1];
    [_ckjdBtn setTitle:@"查看接待" forState:UIControlStateNormal];
    _ckjdBtn.titleLabel.font  = [UIFont systemFontOfSize: 14];
    [_ckjdBtn addTarget:self action:@selector(onBtn1Click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_ckjdBtn];
    
    _jsrwBtn  = [[UIButton alloc]initWithFrame:CGRectMake(5 + (SCREEN_WIDTH - 10)/5 , 5 +64, (SCREEN_WIDTH - 14)/5, 30)];
    _jsrwBtn.backgroundColor = [UIColor colorWithRed:0.09 green:0.63 blue:0.52 alpha:1];
    [_jsrwBtn setTitle:@"接受任务" forState:UIControlStateNormal];
    _jsrwBtn.titleLabel.font  = [UIFont systemFontOfSize: 14];
    [_jsrwBtn addTarget:self action:@selector(onBtn2Click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_jsrwBtn];
    
    _lxkhBtn  = [[UIButton alloc]initWithFrame:CGRectMake(5 + (SCREEN_WIDTH - 10)/5 * 2, 5 +64, (SCREEN_WIDTH - 14)/5, 30)];
    _lxkhBtn.backgroundColor = [UIColor colorWithRed:0.83 green:0.33 blue:0 alpha:1];
    [_lxkhBtn setTitle:@"联系客户" forState:UIControlStateNormal];
    _lxkhBtn.titleLabel.font  = [UIFont systemFontOfSize: 14];
    [_lxkhBtn addTarget:self action:@selector(onBtn3Click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_lxkhBtn];
    
    _yjxhBtn  = [[UIButton alloc]initWithFrame:CGRectMake(5 + (SCREEN_WIDTH - 10)/5 * 3, 5 +64, (SCREEN_WIDTH - 14)/5, 30)];
    _yjxhBtn.backgroundColor = [UIColor colorWithRed:0.16 green:0.50 blue:0.73 alpha:1];
    [_yjxhBtn setTitle:@"已经修好" forState:UIControlStateNormal];
    _yjxhBtn.titleLabel.font  = [UIFont systemFontOfSize: 14];
    [_yjxhBtn addTarget:self action:@selector(onBtn4Click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_yjxhBtn];
    
    _gbrwBtn  = [[UIButton alloc]initWithFrame:CGRectMake(5 + (SCREEN_WIDTH - 10)/5 * 4 , 5 +64, (SCREEN_WIDTH - 14)/5, 30)];
    _gbrwBtn.backgroundColor = [UIColor colorWithRed:0.09 green:0.63 blue:0.52 alpha:1];
    [_gbrwBtn setTitle:@"关闭任务" forState:UIControlStateNormal];
    _gbrwBtn.titleLabel.font  = [UIFont systemFontOfSize: 14];
    [_gbrwBtn addTarget:self action:@selector(onBtn5Click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:_gbrwBtn];

    NSString *str = [NSString stringWithFormat:@"接待描述 ：%@",[_dataDic valueForKey:@"rcontent"]];
    //根据文字的大小和数量自定义label的高度的代码
    CGSize size = CGSizeMake(SCREEN_WIDTH - 40,CGFLOAT_MAX);
    UIFont* theFont = [UIFont systemFontOfSize:15];
    //    //计算文字所占区域
    CGSize labelSize = [str boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : theFont} context:nil].size;
  //  NSLog(@"%@",labelSize.height);
    //    View1
    _view1 = [[UIView alloc]initWithFrame:CGRectMake(10, 10, SCREEN_WIDTH  - 20, labelSize.height + 100)];
    _view1.backgroundColor = [UIColor whiteColor];
    //_view1.layer.borderColor = [[UIColor redColor] CGColor];
//    _view1.layer.borderWidth  = 1;
    _view1.layer.cornerRadius = 10;
    [_scrollV addSubview:_view1];
    
    UILabel *roomLabel  = [[UILabel alloc]initWithFrame:CGRectMake(10, 10   , _view1.bounds.size.width - 20 , 20)];
    roomLabel.text = [NSString stringWithFormat:@"房  间 ：%@",[_dataDic valueForKey:@"room"] ];
    roomLabel.textColor = [UIColor lightGrayColor];
    [_view1 addSubview:roomLabel];
    
    UILabel *lxrLabel  = [[UILabel alloc]initWithFrame:CGRectMake(10, 30 , _view1.bounds.size.width - 20 , 20)];
    lxrLabel.text = [NSString stringWithFormat:@"联 系 人 ：%@",[_dataDic valueForKey:@"contact"]];
    lxrLabel.textColor = [UIColor lightGrayColor];
    [_view1 addSubview:lxrLabel];
    
    UILabel *telLabel  = [[UILabel alloc]initWithFrame:CGRectMake(10, 50   , _view1.bounds.size.width - 20 , 20)];
    telLabel.text = [NSString stringWithFormat:@"电  话 ：%@",[_dataDic valueForKey:@"tel"]];
    telLabel.textColor = [UIColor lightGrayColor];
    UIButton *button  = [[UIButton alloc]initWithFrame:CGRectMake(_view1.bounds.size.width - 30, 50, 20, 20)];
    [button setBackgroundImage:[UIImage imageNamed:@"common_btn_phone"] forState:UIControlStateNormal];
    [button addTarget:self action:@selector(makePhone) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor colorWithRed:0.24 green:0.43 blue:0.64 alpha:1];
    button.layer.cornerRadius = 3;
    [_view1 addSubview:button];
    [_view1 addSubview:telLabel];
    
    _jsmsLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 70, _view1.frame.size.width -20 , labelSize.height + 20)];
    _jsmsLabel.font = [UIFont systemFontOfSize:15];
    //_jsmsLabel.backgroundColor = [UIColor redColor];
    _jsmsLabel.text = str;
    [_jsmsLabel setNumberOfLines:0];
    _jsmsLabel.lineBreakMode = NSLineBreakByWordWrapping;
    _jsmsLabel.textColor = [UIColor lightGrayColor];
    [_view1 addSubview:_jsmsLabel];
    
    
    //    View2
    _view21 = [[UIView alloc]initWithFrame:CGRectMake(10, labelSize.height + 100 + 20, (SCREEN_WIDTH  - 40)/3, 50)];
    _view21.backgroundColor = [UIColor whiteColor];
    //_view2.layer.borderColor = [[UIColor redColor] CGColor];
    //_view2.layer.borderWidth  = 1;
    _view21.layer.cornerRadius = 10;
    [_scrollV addSubview:_view21];
    UILabel *ztLabel1  = [[UILabel alloc]initWithFrame:CGRectMake(10, 5   , 1150 , 20)];
    ztLabel1.text = @"状态";
    ztLabel1.textColor = [UIColor lightGrayColor];
    [_view21 addSubview:ztLabel1];
    UILabel *ztLabel2  = [[UILabel alloc]initWithFrame:CGRectMake(10, 25   , 1150 , 20)];
    ztLabel2.text = [NSString stringWithFormat:@"    %@",[[_Array valueForKey:@"data"] valueForKey:@"state"]];
    ztLabel2.textColor = [UIColor lightGrayColor];
    ztLabel2.font = [UIFont systemFontOfSize:15];
    [_view21 addSubview:ztLabel2];
    
    
    
    _view22 = [[UIView alloc]initWithFrame:CGRectMake(20 +(SCREEN_WIDTH  - 40)/3, labelSize.height + 100 + 20,(SCREEN_WIDTH  - 40)/3, 50)];
    _view22.backgroundColor = [UIColor whiteColor];
    //_view2.layer.borderColor = [[UIColor redColor] CGColor];
    //_view2.layer.borderWidth  = 1;
    _view22.layer.cornerRadius = 10;
    [_scrollV addSubview:_view22];
    UILabel *lxLabel1  = [[UILabel alloc]initWithFrame:CGRectMake(10, 5   , 1150 , 20)];
    lxLabel1.text = @"类型";
    lxLabel1.textColor = [UIColor lightGrayColor];
    [_view22 addSubview:lxLabel1];
    UILabel *lxLabel2  = [[UILabel alloc]initWithFrame:CGRectMake(10, 25   , 1150 , 20)];
    lxLabel2.text = [NSString stringWithFormat:@"    %@",[_dataDic  valueForKey:@"type"]];
    lxLabel2.textColor = [UIColor lightGrayColor];
    lxLabel2.font = [UIFont systemFontOfSize:15];
    [_view22 addSubview:lxLabel2];
    
    
    
    _view23 = [[UIView alloc]initWithFrame:CGRectMake(30 +(SCREEN_WIDTH  - 40)/3 *2,  labelSize.height + 100 + 20, (SCREEN_WIDTH  - 40)/3, 50)];
    _view23.backgroundColor = [UIColor whiteColor];
    //_view2.layer.borderColor = [[UIColor redColor] CGColor];
    //_view2.layer.borderWidth  = 1;
    _view23.layer.cornerRadius = 10;
    [_scrollV addSubview:_view23];
    UILabel *jbLabel1  = [[UILabel alloc]initWithFrame:CGRectMake(10, 5   , 1150 , 20)];
    jbLabel1.text = @"级别";
    jbLabel1.textColor = [UIColor lightGrayColor];
    [_view23 addSubview:jbLabel1];
    UILabel *jbLabel2  = [[UILabel alloc]initWithFrame:CGRectMake(10, 25   , 1150 , 20)];
    jbLabel2.text = [NSString stringWithFormat:@"    %@",[_dataDic valueForKey:@"level"]];
    jbLabel2.textColor = [UIColor lightGrayColor];
    jbLabel2.font = [UIFont systemFontOfSize:15];
    [_view23 addSubview:jbLabel2];
    
    //    view3
    _view3 = [[UIView alloc]initWithFrame:CGRectMake(10, labelSize.height + 180, SCREEN_WIDTH  - 20, 100)];
    _view3.backgroundColor = [UIColor whiteColor];
    _view3.layer.borderColor = [[UIColor redColor] CGColor];
    _view3.layer.borderWidth  = 1;
    _view3.layer.cornerRadius = 10;
    [_scrollV addSubview:_view3];
    
    for (int  i = 0; i < 4; i ++) {
        UILabel *label  = [[UILabel alloc]initWithFrame:CGRectMake(5, 25*i, _view3.bounds.size.width  - 10, 1)];
        label.layer.borderWidth = 1;
        label.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        [_view3 addSubview:label];
    }
    
    NSArray *ary = @[[NSString stringWithFormat:@"受 理 人 ：%@",[_dataDic valueForKey:@"receiver"] ],[NSString stringWithFormat:@"受理时间 ：%@",[_dataDic valueForKey:@"taskTime"] ],[NSString stringWithFormat:@"派工时间 ：%@",[_dataDic valueForKey:@"createTime"] ],[NSString stringWithFormat:@"任务主题 ：%@",[_dataDic valueForKey:@"title"] ]];
    for (int  i = 0; i < 4; i ++) {
        UILabel *labelview3  = [[UILabel alloc]initWithFrame:CGRectMake(10, 25*i, _view3.bounds.size.width  - 10, 25)];
        labelview3.font = [UIFont systemFontOfSize:15];
        labelview3.text = ary[i];
        labelview3.textColor = [UIColor lightGrayColor];
        [_view3 addSubview:labelview3];
    }
    
    //    view4
    _view4 = [[UIView alloc]initWithFrame:CGRectMake(10, 290 +labelSize.height , SCREEN_WIDTH  - 20, 45)];
    _view4.backgroundColor = [UIColor whiteColor];
    _view4.layer.borderColor = [[UIColor redColor] CGColor];
    _view4.layer.borderWidth  = 1;
    _view4.layer.cornerRadius = 10;
    [_scrollV addSubview:_view4];
    
    _labelview4  = [[UILabel alloc]initWithFrame:CGRectMake(10, 0, _view3.bounds.size.width  - 20, 45)];
    _labelview4.text = [NSString stringWithFormat:@"后续受理人：%@",[_dataDic valueForKey:@"followReceiver"]];
    _labelview4.textColor = [UIColor lightGrayColor];
    [_view4 addSubview:_labelview4];
    UIButton *buttonHX  = [[UIButton alloc]initWithFrame:CGRectMake(_view4.bounds.size.width - 44, 1, 43, 43)];
    [buttonHX setBackgroundImage:[UIImage imageNamed:@"task_btn_edit"] forState:UIControlStateNormal];
    buttonHX.backgroundColor = [UIColor colorWithRed:0.24 green:0.43 blue:0.64 alpha:1];
    [buttonHX addTarget:self action:@selector(onHXBtnClick) forControlEvents:UIControlEventTouchUpInside];
    buttonHX.layer.cornerRadius = 10;
    [_view4 addSubview:buttonHX];
    
    //    view5
    //计算文字所占区域
    CGSize xqlabelSize = [[NSString stringWithFormat:@"任务详情 ：%@",[_dataDic valueForKey:@"content"]] boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : theFont} context:nil].size;
    _view5 = [[UIView alloc]initWithFrame:CGRectMake(10, 345 +labelSize.height, SCREEN_WIDTH  - 20, 125 + xqlabelSize.height + 10)];
    _view5.backgroundColor = [UIColor whiteColor];
    _view5.layer.borderColor = [[UIColor redColor] CGColor];
    _view5.layer.borderWidth  = 1;
    _view5.layer.cornerRadius = 10;
    [_scrollV addSubview:_view5];
    
    for (int  i = 0; i < 6; i ++) {
        UILabel *label  = [[UILabel alloc]initWithFrame:CGRectMake(5, 25*i, _view5.bounds.size.width  - 10, 1)];
        label.layer.borderWidth = 1;
        label.layer.borderColor = [[UIColor lightGrayColor] CGColor];
        [_view5 addSubview:label];
    }
    NSArray *ary2 = @[[NSString stringWithFormat:@"责任单位 ：%@",[_dataDic valueForKey:@"accountability"] ],[NSString stringWithFormat:@"第三方处理单位 ：%@",[_dataDic valueForKey:@"thirdPart"] ],[NSString stringWithFormat:@"答复客户时限 ：%@",[_dataDic valueForKey:@"answerTime"] ],[NSString stringWithFormat:@"承诺完成时间 ：%@",[_dataDic valueForKey:@"promiseTime"] ],[NSString stringWithFormat:@"任务处理时间 ：%@",[_dataDic valueForKey:@"handleTime"] ],[NSString stringWithFormat:@"任务详情 ：%@",[_dataDic valueForKey:@"content"] ]];
    for (int  i = 0; i < 5; i ++) {
        UILabel *labelview3  = [[UILabel alloc]initWithFrame:CGRectMake(10, 25*i , _view5.bounds.size.width  - 10, 25)];
        labelview3.font = [UIFont systemFontOfSize:15];
        labelview3.text = ary2[i];
        labelview3.textColor = [UIColor lightGrayColor];
        [_view5 addSubview:labelview3];
    }
    
    UILabel *xqlabelview  = [[UILabel alloc]initWithFrame:CGRectMake(10, 125 , _view5.bounds.size.width  - 20, xqlabelSize.height + 10)];
    xqlabelview.font = [UIFont systemFontOfSize:15];
    xqlabelview.text = [NSString stringWithFormat:@"任务详情 ：%@",[_dataDic valueForKey:@"content"]];
    [xqlabelview setNumberOfLines:0];
    xqlabelview.lineBreakMode = NSLineBreakByWordWrapping;
    xqlabelview.textColor = [UIColor lightGrayColor];
    [_view5 addSubview:xqlabelview];
    
}

//修改后续受理人
-(void)onHXBtnClick{

    if ([[_dataDic valueForKey:@"receiver"] isEqualToString:[GCMUserInfo instance].realName]){

        GCMSLRViewController *main =[[GCMSLRViewController alloc]init];
        main.type = @"1";
//        3.设置回调的block
        main.returnStrBlock = ^(NSString * str){
            _labelview4.text = [NSString stringWithFormat:@"后续受理人：%@", str];
            _labelview4.textColor = [UIColor lightGrayColor];
//           修改受理人
            NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
            parameters[@"userName"] = str;
            parameters[@"taskId"] = self.idd;
            
            [GCMTaskHttpRequst postDataWithParmerts:parameters WithUrl:TASKUPDATAFOLLOWCONTACT_URL Success:^(id obj, NSError *err) {
                //NSLog(@"qqqqqq%@",obj);
            }];
        };
        [self.navigationController pushViewController:main animated:YES];
        UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
        backItem.title = @"成员选择";
        self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
        self.navigationItem.backBarButtonItem = backItem;
        
    }else{
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"只有受理人才能修改后续受理人" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
        
    }

}

-(void)onBtn1Click{

    GCMReciveDetailViewController *receiveDetailVC = [[GCMReciveDetailViewController alloc]init];
    receiveDetailVC.idd = [_dataDic valueForKey:@"rid"];
    NSLog(@"%@",receiveDetailVC.idd);
    [self.navigationController pushViewController:receiveDetailVC animated:YES];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"接待处理";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.backBarButtonItem = backItem;
    
}

-(void)onBtn2Click{

    if ([[_dataDic valueForKey:@"followReceiver"] isEqualToString:[GCMUserInfo instance].realName]){
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"确定接受该任务？" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        alertView.tag = 5141;
        [alertView show];
    
    }else{
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"当前权限不足" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView show];
        
    }
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{

    if (alertView.tag == 5141) {
    
    if (buttonIndex == 1) {
    
        NSDictionary *dic = [[NSDictionary alloc]init];
        dic = [CZHChangeNullString getValueFromDictionary:[_Array valueForKey:@"data"]];
        
        NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
        parameters[@"receiveId"] = [dic valueForKey:@"rid"];
        parameters[@"taskId"] = self.idd;
        parameters[@"createName"] = [dic valueForKey:@"createname"];
        parameters[@"state"] = @"处理中";
        parameters[@"followReceiver"] = [dic valueForKey:@"followReceiver"];
        parameters[@"receiver"] = [dic valueForKey:@"receiver"];
        parameters[@"content"] = [dic valueForKey:@"rcontent"];
        parameters[@"remark1"] = @"";
        parameters[@"remark2"] = @"";
        parameters[@"remark3"] = @"";
        parameters[@"images"] = @"";
      
        NSLog(@"测试%@",parameters);
        [GCMTaskHttpRequst postDataWithParmerts:parameters WithUrl:TASKADDPROGRESS_URL Success:^(id obj, NSError *err) {
            NSLog(@"88888%@",obj);
        }];
    }
    }
    if (alertView.tag == 5142) {
        if (buttonIndex == 1) {
            
            NSDictionary *dic = [[NSDictionary alloc]init];
            dic = [CZHChangeNullString getValueFromDictionary:[_Array valueForKey:@"data"]];
            
            NSMutableDictionary *parameters = [[NSMutableDictionary alloc]init];
            parameters[@"receiveId"] = [dic valueForKey:@"rid"];
            parameters[@"taskId"] = self.idd;
            parameters[@"createName"] = [dic valueForKey:@"createname"];
            parameters[@"state"] = @"已完成";
            parameters[@"followReceiver"] = [dic valueForKey:@"followReceiver"];
            parameters[@"receiver"] = [dic valueForKey:@"receiver"];
            parameters[@"content"] = [dic valueForKey:@"rcontent"];
            parameters[@"remark1"] = @"";
            parameters[@"remark2"] = @"";
            parameters[@"remark3"] = @"";
            parameters[@"iamges"] = @"";
            NSLog(@"测试%@",parameters);
            
            [GCMTaskHttpRequst postDataWithParmerts:parameters WithUrl:TASKADDPROGRESS_URL Success:^(id obj, NSError *err) {
                //NSLog(@"88888%@",obj);
            }];
        }
        
    }
    
}
-(void)onBtn3Click{

    GCMLXKHViewController *lxkh =[[GCMLXKHViewController alloc]init];
    lxkh.idd = self.idd;
//    NSLog(@"11111%@",self.idd);
    lxkh.contact = [_dataDic valueForKey:@"contact"];
    //lxkh.createName = [[_Array valueForKey:@"data"] valueForKey:@"rcontent"];
    [self.navigationController pushViewController:lxkh animated:YES];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"联系客户记录";
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.backBarButtonItem = backItem;
    
}

-(void)onBtn4Click{
    if ([[_dataDic valueForKey:@"followReceiver"] isEqualToString:[GCMUserInfo instance].realName]) {
    
    UIAlertView *alertView2 = [[UIAlertView alloc] initWithTitle:@"确定汇报完成？" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    alertView2.tag = 5142;
    [alertView2 show];
    }else{
        UIAlertView *alertView10 = [[UIAlertView alloc] initWithTitle:@"当前身份权限不足" message:@"" delegate:self cancelButtonTitle:nil otherButtonTitles:@"确定", nil];
        [alertView10 show];
        
    }
}

-(void)onBtn5Click{
    //NSLog(@"00000%@",[[_Array valueForKey:@"data"] valueForKey:@"state"]);
    if ([[_dataDic valueForKey:@"state"] isEqualToString:@"已关闭"]){
        UIAlertView *alertView9 = [[UIAlertView alloc] initWithTitle:@"任务已是关闭状态" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView9 show];
    }else if ([[_dataDic valueForKey:@"state"] isEqualToString:@"待处理"]){
        UIAlertView *alertView8 = [[UIAlertView alloc] initWithTitle:@"任务还是待处理状态" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView8 show];
    }else if ([[_dataDic valueForKey:@"state"] isEqualToString:@"处理中"]){
        UIAlertView *alertView7 = [[UIAlertView alloc] initWithTitle:@"任务还是处理中状态" message:@"" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView7 show];
    }else if(![[_dataDic valueForKey:@"createname"] isEqualToString:[GCMUserInfo instance].realName]){
        NSLog(@"%@",_dataDic);
    
        UIAlertView *alertView6 = [[UIAlertView alloc] initWithTitle:@"权限不足" message:@"只有任务创建人可以关闭任务" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alertView6 show];
        
    }else{
        
    GCMCloseTaskViewController *cleseVC =[[GCMCloseTaskViewController alloc]init];
    [self.navigationController pushViewController:cleseVC animated:YES];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] init];
    backItem.title = @"关闭任务";
    cleseVC.idd = self.idd;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    self.navigationItem.backBarButtonItem = backItem;
        
    }
    
}


-(void)makePhone{
    //    调用手机拨号
    NSString *phone=  [_dataDic valueForKey:@"tel"];
    //NSString *phone= @"18454262099";
    NSMutableString *str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",phone];
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
